package org.lc.oauth.util;


import org.lc.platform.base.util.SmEncryptUtil;
import org.springframework.security.crypto.password.PasswordEncoder;

import java.util.Objects;

public class Sm4PasswordEncoder implements PasswordEncoder {

    @Override
    public String encode(CharSequence rawPassword) {
        return SmEncryptUtil.passWordEncrypt(rawPassword.toString());
    }

    @Override
    public boolean matches(CharSequence rawPassword, String encodedPassword) {
        return Objects.equals(encodedPassword, SmEncryptUtil.passWordEncrypt(rawPassword.toString()));
    }
}